﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using TagCSHelpers.Helpers;

namespace HttpHelperTest
{
    public class SK
    {
        private string signature = string.Empty;




        public void init()
        {
            var req = new TagCSHelpers.Helpers.Http.Request();
            req.Url = "http://wyx.cnskg.net/20150921/sample.php?callback=jQuery17208414281976874918_1442914665377&appid=wx7a2f2fd1a9b69636&appsecret=db930feb46ab3233b1f862442b15e9bb&url=http%3A%2F%2Fwyx.cnskg.net%2F20150921%2Ftp.php%3Ffrom%3Dgroupmessage%26isappinstalled%3D0&xm_name=123asd&_=" + DateTime.Now.Millisecond;

            var res = req.GetResponse();

            signature = Regex.Match(res.Content, "signature\":\"([a-z0-9]*)\"").Groups[1].Value;

            Console.WriteLine("获取到openid:{0}",signature);
        }
        public void vote()
        {
            var req = new TagCSHelpers.Helpers.Http.Request();
            req.Url = "http://wyx.cnskg.net/20150921/ranking.php";
            req.Method = TagCSHelpers.Helpers.Http.HttpMethod.POST;
            req.UserAgent = "User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_2 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B440 MicroMessenger/6.2.6 NetType/WIFI Language/zh_CN";
            req.ProtocolVersion = HttpVersion.Version11;
            req.PostData = "type=ranking&itemno%5B%5D=15&itemno%5B%5D=10&itemno%5B%5D=11&cmdid=12&openid="+signature+"&voteid=13105&uid=199&wx_actid=5935";


            var res = req.GetResponse();

            Console.WriteLine("投票结果：{0}",res.Content);
        }
    }
}
